import requests
from lxml import etree
import urllib.request


def img_list(page):
    url = "https://www.ivsky.com/tupian/chengshilvyou/index_" + str(page) + ".html"
    response = requests.get(url=url)
    response.encoding = "utf-8"
    tree = etree.HTML(response.text)
    img_list = tree.xpath("//div/ul[@class='ali']/li")
    for i in img_list:
        name = i.xpath("./div/a/img/@alt")[0]
        filename = "./img_11/" + name + ".jpg"
        src = i.xpath("./div/a/img/@src")[0]
        src2 = "https:" + src
        urllib.request.urlretrieve(url=src2, filename=filename)
        print(name + "----" + src2)


if __name__ == '__main__':
    for j in range(1, 10):
        img_list(j)
